# $Id$
# Maintainer (ArchLinux): Andrea Scarpino <andrea@archlinux.org>
# Maintainer (MSYS2): Ray Donnelly <mingw.android@gmail.com>

_realname=extra-cmake-modules
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=5.74.0
pkgrel=1
pkgdesc='Extra CMake modules (mingw-w64)'
arch=('any')
url='https://projects.kde.org/projects/kdesupport/extra-cmake-modules'
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-cmake"
         "${MINGW_PACKAGE_PREFIX}-png2ico")
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-sphinx"
             "${MINGW_PACKAGE_PREFIX}-python3-requests")
source=("https://download.kde.org/stable/frameworks/${pkgver%.*}/${_realname}-${pkgver}.tar.xz"
        "set-AUTOSTATICPLUGINS.patch")
sha256sums=('71406067bcd99ac106e0e3bfbb073653b18fd6d01039c0298d9767680977364f'
            'a246d25065ac7472b3a4e5995b3c6cb32081ffa21c7de7455006398431e6c886')

prepare() {
  mkdir -p build-${CARCH}

  # Apply patches
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/set-AUTOSTATICPLUGINS.patch"
}

build() {
  mkdir -p build-${CARCH}
  cd build-${CARCH}
  MSYS2_ARG_CONV_EXCL=-DCMAKE_INSTALL_PREFIX= \
  cmake ../${_realname}-${pkgver} \
    -G'MSYS Makefiles' \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_HTML_DOCS=OFF \
    -DBUILD_QTHELP_DOCS=OFF \
    -DBUILD_TESTING=OFF

  make
}

package() {
  cd build-${CARCH}
  make DESTDIR="${pkgdir}" install
}
